import defaultConfig from '@/config/env'

// 分享
let wxShare = {
	onShareAppMessage(e) {
		if (e.from === "button" && e.target.dataset.obj) {
			// button 按钮分享
			let obj = e.target.dataset.obj // 获取 button 组件 自定义的data-obj值
			console.log(obj)
			return {
				title: obj.title || defaultConfig[defaultConfig.mchType].appName, // 标题
				path: obj.path || '/pages/index/index/index', // URL
				imageUrl: obj.imageUrl || '', // 封面图
			};
		} else {
			return {
				title: this.shareData.title || defaultConfig[defaultConfig.mchType].appName,
				path: this.shareData.path || '/pages/index/index/index',
				imageUrl: this.shareData.imageUrl || ''
			}
		}
		
	},
	onShareTimeline() {
		let query = this.shareData.path ? this.shareData.path.split('?')[1] : ''
		console.log(query)
		return {
			title: this.shareData.title || defaultConfig[defaultConfig.mchType].appName,
			query: query,
			imageUrl: this.shareData.imageUrl || ''
		}
	},
}
export default wxShare;